package org.ysh.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * WebMvc配置
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    public void addViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry registry) {
        //注册一个视图控制器，访问/路径，跳转到index页面
        registry.addViewController("/").setViewName("index");
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);

        super.addViewControllers(registry);
    }


    public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
        // 注册拦截器
        registry.addInterceptor(new ReLoginForbiddenInterceptor()).addPathPatterns("/login**");

        super.addInterceptors(registry);
    }


}
